﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebeTerm.PlugIns;

namespace WebeTerm.GetRebate
{
    /// <summary>
    /// 返扣插件结果
    /// </summary>
    public sealed class RebateResult : BasePlugInResult{

        public RebateResult() {
            Rebates = new List<string>();
        }

        public string PNRCode { get; set; }

        public string Code { get; set; }

        public List<string> Rebates { get; set; }


        public override string ToDisplay()
        {
            return string.Format(@"大编号:{0} PNR:{1} 返扣:[{2}]", Code, PNRCode, string.Join(",", Rebates.ToArray()));
        }

        //public string 
    }

    /// <summary>
    /// 返扣插件配置
    /// </summary>
    public sealed class RebateConfig : BasePlugInConfig {
        [Result(Title = @"航空公司", Description = @"航空公司二字代码", ValueTypeOf = typeof(string))]
        public string AirWayCode { get; set; }


        [Result(Title = @"登录地址", Description = @"代理人登录地址", ValueTypeOf = typeof(string))]
        public string WebLogInUrl { get; set; }


        [Result(Title = @"验证码", Description = @"代理人登录地址", ValueTypeOf = typeof(string))]
        public string CodeUrl { get; set; }


        [Result(Title = @"用户名", Description = @"代理人登录用户名", ValueTypeOf = typeof(string))]
        public string UserName { get; set; }


        [Result(Title = @"密码", Description = @"代理人登录密码", ValueTypeOf = typeof(string))]
        public string Password { get; set; }


        [Result(Title = @"需要验证码", Description = @"登录时是需要填写验证码", ValueTypeOf = typeof(bool))]
        public bool IsRequireVerifyCode { get; set; }


        [Result(Title = @"用户名控件", Description = @"代理人登录用户名", ValueTypeOf = typeof(string))]
        public string UserNameControl { get; set; }


        [Result(Title = @"密码控件", Description = @"代理人登录密码", ValueTypeOf = typeof(string))]
        public string PasswordControl { get; set; }


        [Result(Title = @"验证码控件", Description = @"验证码控件", ValueTypeOf = typeof(string))]
        public string VerifyCodeControl { get; set; }

        /// <summary>
        ///     信息提取页面
        /// <remarks>
        ///     http://agent.hnair.com/hub2b/b2b_pnr_db.do?actionType=getInfoDisplay&isHaveNoSeg=0&pnr=MZKYH7
        ///     \<span\s+id\=\"span_fee_(\d)_\d\"\>\d+(\.\d{0,}){0,1}\((\d+(\.\d{0,}){0,1})\)
        /// </remarks>
        /// </summary>
        [Result(Title = @"信息提取页面", Description = @"信息提取页面", ValueTypeOf = typeof(string))]
        public string RequestUrl { get; set; }

        public string PnrNo { get; set; }

        public string Code { get; set; }
    }
}
